# 快速排序（咸鱼版）
import random

def partition(arr, left, right):
    pivot = arr[left]
    while left < right:
        while arr[right] >= pivot and left < right:
            right -= 1
        arr[left] = arr[right]
        while arr[left] <= pivot and left < right:
            left += 1
        arr[right] = arr[left]
    arr[left] = pivot
    return left

def quick_sort(arr,left,right):
    if left<right:
        mid=partition(arr,left,right)
        quick_sort(arr,left,mid-1)
        quick_sort(arr,mid+1,right)

if __name__ == '__main__':
    arr=[random.randint(0,100) for i in range(10)]
    print(arr)
    quick_sort(arr,0,len(arr)-1)
    print(arr)